<%@ page import="ird.demo.common.DemoConstant" %>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

<script type="text/javascript">
var tableFstLoad = true;

$(function() {
	if('${keyParam.act}' != ''){
		$('input:radio[name="act"][value="${keyParam.act}"]').prop('checked', true);
	}
	
	$('#easyuiDg').datagrid({  
	});
	
});

function preValidate(){
	var act = $('input[name=act]:checked', '#ff').val();
	if(act == "upd"){
		var rows = $('#easyuiDg').datagrid('getSelections');
		if (rows.length != 1) {
			alert("Please select a transaction!");
			//$.messager.alert('Info', 'Please select a transaction!', 'info');
			return false;
		}
	}
	else if (act == "del"){
		var rows = $('#easyuiDg').datagrid('getChecked');
		if (rows.length > 0) {
		    var ids = '';
			for ( var i = 0; i < rows.length; i++) {
						ids += rows[i].tranId + ',';
			}
			ids = ids.substring(0, ids.length - 1);
			if (confirm('Confirm to delete?')) {
				$('#tranIds').val(ids);
			    return true;
			} else {
			    return false;
			}
		} else {
			alert("Please select transactions to be deleted!");
			//$.messager.alert('Info', 'Please select transactions to be deleted!','info');
			return false;
		}
	}
    return true;
}
</script>

<div class="easyui-panel" title="Modify Transaction:">
	<div style="padding:10px 60px 10px 60px">
	<form id="ff" action="<c:url value='/transaction/IRSM0002/detail' />" method='post'>
	<!-- datagrid -->
		<table id="easyuiDg" style="width:1100px;height:500px"
				data-options="
					rownumbers:true,
					singleSelect:true,
					checkOnSelect:false,
					selectOnCheck:false,
					url:'${rootPath}/transaction/IRSM0002/getTranListPage',
					pagination:true,
					pageNumber:${keyParam.page == null? 1:keyParam.page},
					pageSize:${keyParam.rows == null? 15:keyParam.rows},
					pageList:<%=DemoConstant.PAGE_LIST%>,
					onSelect: function(index,row){  
						$('#tranId').val(row.tranId);
						$('#rowIdx').val(index);
				    },
				    onLoadSuccess : function(data) {
				    	var opts = $(this).datagrid('options');
				    	$('#page').val(opts.pageNumber);
				    	$('#rows').val(opts.pageSize);
				    	
				    	//alert(tableFstLoad);
				    	
				    	if('${keyParam.rowIdx}' != '' && tableFstLoad){
							$(this).datagrid('selectRow','${keyParam.rowIdx}');
							tableFstLoad = false;
						}
					},
					">
			<thead>
				<tr>
					<th field="ck" checkbox="true"></th>
					<th field="tranId" width="80" align="center" sortable="true">Transaction</th>
					<th field="tranDesc" width="350" halign="center" sortable="true">Tranaction Desciption</th>
					<th field="systemName" width="80" align="center" sortable="true">System Code</th>
					<th field="menuId" width="80" align="center" sortable="true">System Menu</th>
					<th field="enquiryInd" width="100" align="center" sortable="true">Enquiry</th>
					<th field="tranSuppInd" width="100" align="center" sortable="true" formatter="formatSuppInd">Suppression</th>
					<th field="updateBy" width="100" align="center" sortable="true">Update By</th>
					<th field="updateTs" width="100" align="center" sortable="true">Update Time</th>
				</tr>
			</thead>
		</table>
	
		<table>
			<tr>
				<td>
					<input type="hidden" name="tranId" id="tranId">
					<input type="hidden" name="rowIdx" id="rowIdx">
					<input type="hidden" name="tranIds" id="tranIds">
					<input type="hidden" name="page" id="page">
					<input type="hidden" name="rows" id="rows">
					<input type="radio" name="act" id="actAdd" value="add" checked>Add
					<input type="radio" name="act" id="actUpd" value="upd">Update
					<input type="radio" name="act" id="actDel" value="del">Delete
				</td>
			</tr>
			<tr>
				<td height="10">
					&nbsp;
				</td>
			</tr>
			<tr>
				<td>
					${bodyBtns }
				</td>
			</tr>
		</table>
    </form>
	
    </div>
</div>

